\(\int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^3} \, dx\) [53]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [F(-2)]
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 34, antiderivative size = 124 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^3} \, dx=-\frac {(A-i B) x}{8 a^3}+\frac {(i A-B) \tan ^2(c+d x)}{6 d (a+i a \tan (c+d x))^3}+\frac {i A-7 B}{24 a d (a+i a \tan (c+d x))^2}+\frac {i A+17 B}{24 d \left (a^3+i a^3 \tan (c+d x)\right )} \]

[Out]

-1/8*(A-I*B)*x/a^3+1/6*(I*A-B)*tan(d*x+c)^2/d/(a+I*a*tan(d*x+c))^3+1/24*(I*A-7*B)/a/d/(a+I*a*tan(d*x+c))^2+1/2
4*(I*A+17*B)/d/(a^3+I*a^3*tan(d*x+c))

Rubi [A] (verified)

Time = 0.48 (sec) , antiderivative size = 124, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.118, Rules used = {3676, 3671, 3607, 8} \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^3} \, dx=\frac {17 B+i A}{24 d \left (a^3+i a^3 \tan (c+d x)\right )}-\frac {x (A-i B)}{8 a^3}+\frac {(-B+i A) \tan ^2(c+d x)}{6 d (a+i a \tan (c+d x))^3}+\frac {-7 B+i A}{24 a d (a+i a \tan (c+d x))^2} \]

[In]

Int[(Tan[c + d*x]^2*(A + B*Tan[c + d*x]))/(a + I*a*Tan[c + d*x])^3,x]

[Out]

-1/8*((A - I*B)*x)/a^3 + ((I*A - B)*Tan[c + d*x]^2)/(6*d*(a + I*a*Tan[c + d*x])^3) + (I*A - 7*B)/(24*a*d*(a +
I*a*Tan[c + d*x])^2) + (I*A + 17*B)/(24*d*(a^3 + I*a^3*Tan[c + d*x]))

Rule 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]

Rule 3607

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(-(
b*c - a*d))*((a + b*Tan[e + f*x])^m/(2*a*f*m)), x] + Dist[(b*c + a*d)/(2*a*b), Int[(a + b*Tan[e + f*x])^(m + 1
), x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && EqQ[a^2 + b^2, 0] && LtQ[m, 0]

Rule 3671

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_
.) + (f_.)*(x_)]), x_Symbol] :> Simp[(-(A*b - a*B))*(a*c + b*d)*((a + b*Tan[e + f*x])^m/(2*a^2*f*m)), x] + Dis
t[1/(2*a*b), Int[(a + b*Tan[e + f*x])^(m + 1)*Simp[A*b*c + a*B*c + a*A*d + b*B*d + 2*a*B*d*Tan[e + f*x], x], x
], x] /; FreeQ[{a, b, c, d, e, f, A, B}, x] && NeQ[b*c - a*d, 0] && LtQ[m, -1] && EqQ[a^2 + b^2, 0]

Rule 3676

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_
.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[(-(A*b - a*B))*(a + b*Tan[e + f*x])^m*((c + d*Tan[e + f*x])^n/(2*a*f
*m)), x] + Dist[1/(2*a^2*m), Int[(a + b*Tan[e + f*x])^(m + 1)*(c + d*Tan[e + f*x])^(n - 1)*Simp[A*(a*c*m + b*d
*n) - B*(b*c*m + a*d*n) - d*(b*B*(m - n) - a*A*(m + n))*Tan[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f, A
, B}, x] && NeQ[b*c - a*d, 0] && EqQ[a^2 + b^2, 0] && LtQ[m, 0] && GtQ[n, 0]

Rubi steps \begin{align*} \text {integral}& = \frac {(i A-B) \tan ^2(c+d x)}{6 d (a+i a \tan (c+d x))^3}-\frac {\int \frac {\tan (c+d x) (2 a (i A-B)-a (A-5 i B) \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx}{6 a^2} \\ & = \frac {(i A-B) \tan ^2(c+d x)}{6 d (a+i a \tan (c+d x))^3}+\frac {i A-7 B}{24 a d (a+i a \tan (c+d x))^2}+\frac {i \int \frac {a^2 (i A-7 B)-2 a^2 (A-5 i B) \tan (c+d x)}{a+i a \tan (c+d x)} \, dx}{12 a^4} \\ & = \frac {(i A-B) \tan ^2(c+d x)}{6 d (a+i a \tan (c+d x))^3}+\frac {i A-7 B}{24 a d (a+i a \tan (c+d x))^2}+\frac {i A+17 B}{24 d \left (a^3+i a^3 \tan (c+d x)\right )}-\frac {(A-i B) \int 1 \, dx}{8 a^3} \\ & = -\frac {(A-i B) x}{8 a^3}+\frac {(i A-B) \tan ^2(c+d x)}{6 d (a+i a \tan (c+d x))^3}+\frac {i A-7 B}{24 a d (a+i a \tan (c+d x))^2}+\frac {i A+17 B}{24 d \left (a^3+i a^3 \tan (c+d x)\right )} \\ \end{align*}

Mathematica [A] (verified)

Time = 1.13 (sec) , antiderivative size = 147, normalized size of antiderivative = 1.19 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^3} \, dx=\frac {\sec ^3(c+d x) (-9 (A-i B) \cos (c+d x)+2 (A+i B-6 i A d x-6 B d x) \cos (3 (c+d x))-3 i A \sin (c+d x)-27 B \sin (c+d x)-2 i A \sin (3 (c+d x))+2 B \sin (3 (c+d x))+12 A d x \sin (3 (c+d x))-12 i B d x \sin (3 (c+d x)))}{96 a^3 d (-i+\tan (c+d x))^3} \]

[In]

Integrate[(Tan[c + d*x]^2*(A + B*Tan[c + d*x]))/(a + I*a*Tan[c + d*x])^3,x]

[Out]

(Sec[c + d*x]^3*(-9*(A - I*B)*Cos[c + d*x] + 2*(A + I*B - (6*I)*A*d*x - 6*B*d*x)*Cos[3*(c + d*x)] - (3*I)*A*Si
n[c + d*x] - 27*B*Sin[c + d*x] - (2*I)*A*Sin[3*(c + d*x)] + 2*B*Sin[3*(c + d*x)] + 12*A*d*x*Sin[3*(c + d*x)] -
 (12*I)*B*d*x*Sin[3*(c + d*x)]))/(96*a^3*d*(-I + Tan[c + d*x])^3)

Maple [A] (verified)

Time = 0.08 (sec) , antiderivative size = 128, normalized size of antiderivative = 1.03

method result size
risch \(\frac {i x B}{8 a^{3}}-\frac {x A}{8 a^{3}}+\frac {3 \,{\mathrm e}^{-2 i \left (d x +c \right )} B}{16 a^{3} d}+\frac {i {\mathrm e}^{-2 i \left (d x +c \right )} A}{16 a^{3} d}-\frac {3 \,{\mathrm e}^{-4 i \left (d x +c \right )} B}{32 a^{3} d}+\frac {i {\mathrm e}^{-4 i \left (d x +c \right )} A}{32 a^{3} d}+\frac {{\mathrm e}^{-6 i \left (d x +c \right )} B}{48 a^{3} d}-\frac {i {\mathrm e}^{-6 i \left (d x +c \right )} A}{48 a^{3} d}\) \(128\)
derivativedivides \(\frac {A}{6 d \,a^{3} \left (\tan \left (d x +c \right )-i\right )^{3}}+\frac {i B}{6 d \,a^{3} \left (\tan \left (d x +c \right )-i\right )^{3}}-\frac {A}{8 d \,a^{3} \left (\tan \left (d x +c \right )-i\right )}-\frac {7 i B}{8 d \,a^{3} \left (\tan \left (d x +c \right )-i\right )}-\frac {A \arctan \left (\tan \left (d x +c \right )\right )}{8 d \,a^{3}}+\frac {i B \arctan \left (\tan \left (d x +c \right )\right )}{8 d \,a^{3}}-\frac {3 i A}{8 d \,a^{3} \left (\tan \left (d x +c \right )-i\right )^{2}}+\frac {5 B}{8 d \,a^{3} \left (\tan \left (d x +c \right )-i\right )^{2}}\) \(158\)
default \(\frac {A}{6 d \,a^{3} \left (\tan \left (d x +c \right )-i\right )^{3}}+\frac {i B}{6 d \,a^{3} \left (\tan \left (d x +c \right )-i\right )^{3}}-\frac {A}{8 d \,a^{3} \left (\tan \left (d x +c \right )-i\right )}-\frac {7 i B}{8 d \,a^{3} \left (\tan \left (d x +c \right )-i\right )}-\frac {A \arctan \left (\tan \left (d x +c \right )\right )}{8 d \,a^{3}}+\frac {i B \arctan \left (\tan \left (d x +c \right )\right )}{8 d \,a^{3}}-\frac {3 i A}{8 d \,a^{3} \left (\tan \left (d x +c \right )-i\right )^{2}}+\frac {5 B}{8 d \,a^{3} \left (\tan \left (d x +c \right )-i\right )^{2}}\) \(158\)

[In]

int(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))^3,x,method=_RETURNVERBOSE)

[Out]

1/8*I*x/a^3*B-1/8*x/a^3*A+3/16/a^3/d*exp(-2*I*(d*x+c))*B+1/16*I/a^3/d*exp(-2*I*(d*x+c))*A-3/32/a^3/d*exp(-4*I*
(d*x+c))*B+1/32*I/a^3/d*exp(-4*I*(d*x+c))*A+1/48/a^3/d*exp(-6*I*(d*x+c))*B-1/48*I/a^3/d*exp(-6*I*(d*x+c))*A

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 78, normalized size of antiderivative = 0.63 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^3} \, dx=-\frac {{\left (12 \, {\left (A - i \, B\right )} d x e^{\left (6 i \, d x + 6 i \, c\right )} + 6 \, {\left (-i \, A - 3 \, B\right )} e^{\left (4 i \, d x + 4 i \, c\right )} + 3 \, {\left (-i \, A + 3 \, B\right )} e^{\left (2 i \, d x + 2 i \, c\right )} + 2 i \, A - 2 \, B\right )} e^{\left (-6 i \, d x - 6 i \, c\right )}}{96 \, a^{3} d} \]

[In]

integrate(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))^3,x, algorithm="fricas")

[Out]

-1/96*(12*(A - I*B)*d*x*e^(6*I*d*x + 6*I*c) + 6*(-I*A - 3*B)*e^(4*I*d*x + 4*I*c) + 3*(-I*A + 3*B)*e^(2*I*d*x +
 2*I*c) + 2*I*A - 2*B)*e^(-6*I*d*x - 6*I*c)/(a^3*d)

Sympy [A] (verification not implemented)

Time = 0.29 (sec) , antiderivative size = 258, normalized size of antiderivative = 2.08 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^3} \, dx=\begin {cases} \frac {\left (\left (- 512 i A a^{6} d^{2} e^{6 i c} + 512 B a^{6} d^{2} e^{6 i c}\right ) e^{- 6 i d x} + \left (768 i A a^{6} d^{2} e^{8 i c} - 2304 B a^{6} d^{2} e^{8 i c}\right ) e^{- 4 i d x} + \left (1536 i A a^{6} d^{2} e^{10 i c} + 4608 B a^{6} d^{2} e^{10 i c}\right ) e^{- 2 i d x}\right ) e^{- 12 i c}}{24576 a^{9} d^{3}} & \text {for}\: a^{9} d^{3} e^{12 i c} \neq 0 \\x \left (- \frac {- A + i B}{8 a^{3}} + \frac {\left (- A e^{6 i c} + A e^{4 i c} + A e^{2 i c} - A + i B e^{6 i c} - 3 i B e^{4 i c} + 3 i B e^{2 i c} - i B\right ) e^{- 6 i c}}{8 a^{3}}\right ) & \text {otherwise} \end {cases} + \frac {x \left (- A + i B\right )}{8 a^{3}} \]

[In]

integrate(tan(d*x+c)**2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))**3,x)

[Out]

Piecewise((((-512*I*A*a**6*d**2*exp(6*I*c) + 512*B*a**6*d**2*exp(6*I*c))*exp(-6*I*d*x) + (768*I*A*a**6*d**2*ex
p(8*I*c) - 2304*B*a**6*d**2*exp(8*I*c))*exp(-4*I*d*x) + (1536*I*A*a**6*d**2*exp(10*I*c) + 4608*B*a**6*d**2*exp
(10*I*c))*exp(-2*I*d*x))*exp(-12*I*c)/(24576*a**9*d**3), Ne(a**9*d**3*exp(12*I*c), 0)), (x*(-(-A + I*B)/(8*a**
3) + (-A*exp(6*I*c) + A*exp(4*I*c) + A*exp(2*I*c) - A + I*B*exp(6*I*c) - 3*I*B*exp(4*I*c) + 3*I*B*exp(2*I*c) -
 I*B)*exp(-6*I*c)/(8*a**3)), True)) + x*(-A + I*B)/(8*a**3)

Maxima [F(-2)]

Exception generated. \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^3} \, dx=\text {Exception raised: RuntimeError} \]

[In]

integrate(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))^3,x, algorithm="maxima")

[Out]

Exception raised: RuntimeError >> ECL says: expt: undefined: 0 to a negative exponent.

Giac [A] (verification not implemented)

none

Time = 0.69 (sec) , antiderivative size = 129, normalized size of antiderivative = 1.04 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^3} \, dx=-\frac {\frac {6 \, {\left (i \, A + B\right )} \log \left (\tan \left (d x + c\right ) + i\right )}{a^{3}} + \frac {6 \, {\left (-i \, A - B\right )} \log \left (\tan \left (d x + c\right ) - i\right )}{a^{3}} + \frac {11 i \, A \tan \left (d x + c\right )^{3} + 11 \, B \tan \left (d x + c\right )^{3} + 45 \, A \tan \left (d x + c\right )^{2} + 51 i \, B \tan \left (d x + c\right )^{2} - 21 i \, A \tan \left (d x + c\right ) + 75 \, B \tan \left (d x + c\right ) - 3 \, A - 29 i \, B}{a^{3} {\left (\tan \left (d x + c\right ) - i\right )}^{3}}}{96 \, d} \]

[In]

integrate(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))^3,x, algorithm="giac")

[Out]

-1/96*(6*(I*A + B)*log(tan(d*x + c) + I)/a^3 + 6*(-I*A - B)*log(tan(d*x + c) - I)/a^3 + (11*I*A*tan(d*x + c)^3
 + 11*B*tan(d*x + c)^3 + 45*A*tan(d*x + c)^2 + 51*I*B*tan(d*x + c)^2 - 21*I*A*tan(d*x + c) + 75*B*tan(d*x + c)
 - 3*A - 29*I*B)/(a^3*(tan(d*x + c) - I)^3))/d

Mupad [B] (verification not implemented)

Time = 7.72 (sec) , antiderivative size = 111, normalized size of antiderivative = 0.90 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^3} \, dx=\frac {{\mathrm {tan}\left (c+d\,x\right )}^2\,\left (-\frac {7\,B}{8\,a^3}+\frac {A\,1{}\mathrm {i}}{8\,a^3}\right )+\frac {A\,1{}\mathrm {i}}{12\,a^3}+\frac {5\,B}{12\,a^3}-\mathrm {tan}\left (c+d\,x\right )\,\left (\frac {A}{8\,a^3}-\frac {B\,9{}\mathrm {i}}{8\,a^3}\right )}{d\,\left (-{\mathrm {tan}\left (c+d\,x\right )}^3\,1{}\mathrm {i}-3\,{\mathrm {tan}\left (c+d\,x\right )}^2+\mathrm {tan}\left (c+d\,x\right )\,3{}\mathrm {i}+1\right )}+\frac {x\,\left (B+A\,1{}\mathrm {i}\right )\,1{}\mathrm {i}}{8\,a^3} \]

[In]

int((tan(c + d*x)^2*(A + B*tan(c + d*x)))/(a + a*tan(c + d*x)*1i)^3,x)

[Out]

(tan(c + d*x)^2*((A*1i)/(8*a^3) - (7*B)/(8*a^3)) + (A*1i)/(12*a^3) + (5*B)/(12*a^3) - tan(c + d*x)*(A/(8*a^3)
- (B*9i)/(8*a^3)))/(d*(tan(c + d*x)*3i - 3*tan(c + d*x)^2 - tan(c + d*x)^3*1i + 1)) + (x*(A*1i + B)*1i)/(8*a^3
)